//
//  GYMineOrderInfoDetailViewModel.m
//  GYDemo
//
//  Created by mac on 2018/4/4.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYMineOrderInfoDetailViewModel.h"
#import "Head.h"

@implementation GYMineOrderInfoDetailGoodsModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{
             @"amount" : @"amount",
             @"count" : @"count",
             @"idField" : @"id",
             @"picurl" : @"imgurl",
             @"price":@"price",
             @"name":@"productName",
             @"proid":@"proid",
             @"protypename":@"typeName",
             @"unit":@"unit"
             };
}
@end

@implementation GYMineOrderInfoDetailModel
+ (NSDictionary *)modelCustomPropertyMapper {
    return @{
             @"amount" : @"amount",
             @"buyid" : @"buyid",
             @"cancelid" : @"cancelid",
             @"cancelreason" : @"cancelreason",
             @"cancelreasonType":@"cancelreasonType",
             @"canceltype":@"canceltype",
             @"companyid":@"companyid",
             @"companyname":@"companyname",
             @"createtime":@"createtime",
             @"descriptionField":@"description",
             @"evalflag":@"evalflag",
             @"evaluateCreatetime":@"evaluateCreatetime",
             @"evaluateGrade":@"evaluateGrade",
             @"evaluateRemark":@"evaluateRemark",
             @"idField":@"id",
             @"mobile":@"mobile",
             @"productList":@"productList",
             @"qq":@"qq",
             @"saleid":@"saleid",
             @"statusName":@"statusName",
             @"transtatus":@"transtatus"
             };
}
@end

@implementation GYMineOrderInfoDetailViewModel
#pragma mark - getter and setter
#pragma mark - method
-(void)requestDetail{
    @WeakSelf;
    NSMutableDictionary *para = [NSMutableDictionary new];
    NSString *ids = [NSString stringWithFormat:@"%@",_orderInfoModel.orderid];
    [para setObject:ids forKey:@"orderid"];
    NSString *interface = @"orderDetail";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        NSDictionary *data = infoModel.data;
        if ([data isKindOfClass:[NSDictionary class]]) {
            GYMineOrderInfoDetailModel *detailModel = [GYMineOrderInfoDetailModel yy_modelWithJSON:data];
            NSArray *productList = detailModel.productList;
            NSMutableArray *mproductList = [NSMutableArray new];
            for (NSDictionary *dic in productList) {
                GYMineOrderInfoDetailGoodsModel *goodsModel = [GYMineOrderInfoDetailGoodsModel yy_modelWithJSON:dic];
                [mproductList addObject:goodsModel];
            }
            detailModel.productList = mproductList;
            [selfp setOrderInfoDetailModel:detailModel];
        }
    }];
}
-(void)requestCancel:(NSMutableDictionary *)para
{
    @WeakSelf;
    NSString *interface = @"cancelOrderWithOrder";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [FTIndicator showSuccessWithMessage:infoModel.message];
        [selfp setUpdateSign:@"true"];
        
    }];
}
-(void)requestEvalate:(NSMutableDictionary *)para
{
    @WeakSelf;
    NSString *interface = @"orderEvaluate";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [FTIndicator showSuccessWithMessage:infoModel.message];
        [selfp setUpdateSign:@"true"];
    }];
}
-(void)requestConfirm:(NSMutableDictionary *)para
{
    @WeakSelf;
    NSString *interface = @"finishOrder";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [FTIndicator showSuccessWithMessage:infoModel.message];
        [selfp setUpdateSign:@"true"];
    }];
}
-(void)requestSave:(NSMutableDictionary *)para
{
    @WeakSelf;
    NSString *interface = @"editOrder";
    [[InterfaceManager shareInterface]requetInterface:interface withParameter:para handler:^(NSDictionary *info, InterfaceStatusModel *infoModel) {
        [FTIndicator showSuccessWithMessage:infoModel.message];
        [selfp setSecUpdateSign:@"true"];
    }];
}
@end
